package com.apobates.forum.toro.core;

/**
 * KideMatcher匹配的结果
 * @deprecated 使用SpaceMatcher
 * @author xiaofanku@live.cn
 * @since 20220829
 */
public final class KideMatcheResult {
    // 匹配到的属性名称
    private final String attribute;
    // 匹配到的属性值
    private final String value;
    // Corner中该属性定义的sequence
    // private final int ranking;
    // 开始分隔符
    private final String start;
    // 结束分隔符
    private final String finish;

    private KideMatcheResult(Builder builder) {
        this.attribute = builder.attribute;
        this.value = builder.value;
        // this.ranking = builder.ranking;
        this.start = builder.start;
        this.finish = builder.finish;
    }

    /**
     * 返回匹配到的属性/Corner.word
     * @return
     */
    public String getAttribute() {
        return attribute;
    }

    /**
     * 返回匹配到的属性值
     * @return
     */
    public String getValue() {
        return value;
    }

    /*
     * 返回匹配到的属性值的排序值/Corner.sequence
     * @return
     *
    public int getRanking() {
        return ranking;
    }*/

    /**
     * 设置匹配结果的开始分隔符
     * @return
     */
    public String getStart() {
        return start;
    }

    /**
     * 返回匹配结果的结束分隔符
     * @return
     */
    public String getFinish() {
        return finish;
    }

    @Override
    public String toString() {
        return "KideMatcheResult{" +
                "attribute='" + attribute + '\'' +
                ", value='" + value + '\'' +
                ", start='" + start + '\'' +
                ", finish='" + finish + '\'' +
                '}';
    }

    public static class Builder{
        // 匹配到的属性名称
        private String attribute;
        // 匹配到的属性值
        private String value;
        // Corner中该属性定义的sequence
        // private int ranking;
        // 开始分隔符
        private String start;
        // 结束分隔符
        private String finish;

        /**
         * 返回一个匹配结果构造器
         * @return
         */
        public static Builder newInstance() {
            return new Builder();
        }
        /**
         * 设置匹配到的属性/Corner.word
         * @param attribute
         * @return
         */
        public Builder attr(String attribute){
            this.attribute = attribute;
            return this;
        }
        /**
         * 设置匹配到的属性值
         * @param value
         * @return
         */
        public Builder val(String value){
            this.value = value;
            return this;
        }
        /*
         * 设置匹配到的属性值的排序值/Corner.sequence
         * @param ranking
         * @return
         *
        public Builder rank(int ranking){
            this.ranking = ranking;
            return this;
        }*/
        /**
         * 设置匹配结果的开始分隔符
         * @param startSymbol
         * @return
         */
        public Builder start(String startSymbol){
            this.start = startSymbol;
            return this;
        }
        /**
         * 设置匹配结果的结束分隔符
         * @param finishSymbol
         * @return
         */
        public Builder finish(String finishSymbol){
            this.finish = finishSymbol;
            return this;
        }
        /**
         * 返回一个匹配结果实例
         * @return
         */
        public KideMatcheResult build(){
            return new KideMatcheResult(this);
        }
    }

}
